﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CharacterSystem : IGameSystem
{
    private List<Character> m_Soldier = new List<Character>();
    private List<Character> m_Enemy = new List<Character>();
    public void Init()
    {
    }

    public void Release()
    {
    }



    public void Update()
    {
        UpdateSoldier();
        UpdateEnemy();
    }




    private void UpdateSoldier()
    {
        foreach(Character s in m_Soldier)
        {
            s.Update();
            s.UpdateFSMAI(m_Enemy);
        }
    }


    private void UpdateEnemy()
    {
        foreach(Character e in m_Enemy)
        {
            e.UpdateFSMAI(m_Soldier);
            e.Update();

        }
    }


    public void AddEnemy(Character enemy)
    {
        if (enemy != null)
        {
            m_Enemy.Add(enemy);
        }
    }


    public void AddSoldier(Character soldier) {
        if (soldier != null)
        {
            m_Soldier.Add(soldier);
        }
        }


    public void DeleteSoldier(Character soldier) {
        if (soldier != null)
        {
            m_Soldier.Remove(soldier);
        }
    }


    public void DeleteEnemy(Character enemy)
    {
        if (enemy != null)
        {
            m_Enemy.Remove(enemy);
        }
    }
}
